/** 
 * 养老护理应用API接口
 * 基于 http://nursing.mguit.com
 * 响应格式: { code: 0, msg: "success", data: {}, url: null, wait: 3 }
 */
import request from './request.js'

// ========== 用户认证相关 ==========
// 用户登录 (不需要token)
export const apiLogin = data => request.post('/api/user/login', data, false)

// 获取用户列表和详细信息 (登录成功后调用)
export const apiGetUserList = data => request.post('/api/user/list', data)

// 获取短信验证码 (不需要token)
export const apiGetSmsCode = data => request.post('/api/sms/code', data, false)

// 手机号登录 (不需要token)
export const apiPhoneLogin = data => request.post('/api/phone/login', data, false)

// 用户注册 (不需要token)
export const apiRegister = data => request.post('/api/register', data, false)

// 用户登出
export const apiLogout = () => request.post('/api/logout', {})

// 刷新token
export const apiRefreshToken = data => request.post('/api/refresh/token', data)

// ========== 用户信息相关 ==========
// 获取用户信息
export const apiGetUserInfo = () => request.post('/api/user/info')

// 更新用户信息
export const apiUpdateUserInfo = data => request.put('/api/user/info', data)

// 修改密码
export const apiChangePassword = data => request.post('/api/user/password', data)

// ========== 老人信息管理 ==========
// 获取老人成员列表
export const apiGetElderlyMembers = data => request.post('/api/user.statistics/member', data)

// 获取老人列表
export const apiGetElderlyList = data => request.post('/api/elderly/list', data)

// 获取老人详情
export const apiGetElderlyDetail = id => request.post(`/api/elderly/${id}`)

// 获取老人详情记录（健康记录、护理记录等）
export const apiGetElderlyDetailRecords = data => request.post('/api/member.Record/index', data)

// 添加老人信息
export const apiAddElderly = data => request.post('/api/elderly', data)

// 更新老人信息
export const apiUpdateElderly = (id, data) => request.put(`/api/elderly/${id}`, data)

// 删除老人信息
export const apiDeleteElderly = id => request.delete(`/api/elderly/${id}`)

// ========== 护理记录相关 ==========
// 获取护理记录列表
export const apiGetCareRecords = data => request.post('/api/care/records', data)

// 添加护理记录
export const apiAddCareRecord = data => request.post('/api/care/record', data)

// 添加老人记录（健康、饮食、用药等综合记录）
export const apiAddElderlyRecord = data => request.post('/api/member.Record/add', data)

// 获取护理记录详情
export const apiGetCareRecordDetail = id => request.post(`/api/care/record/${id}`)

// 更新护理记录
export const apiUpdateCareRecord = (id, data) => request.put(`/api/care/record/${id}`, data)

// ========== 活动管理相关 ==========
// 获取今日待办事件列表（活动、用药、巡检等）
export const apiGetTodayEvents = data => request.post('/api/user.Event/index', data)

// 获取活动列表
export const apiGetActivities = data => request.post('/api/activities', data)

// 获取活动详情
export const apiGetActivityDetail = id => request.post(`/api/activity/${id}`)

// 创建活动
export const apiCreateActivity = data => request.post('/api/activity', data)

// 更新活动
export const apiUpdateActivity = (id, data) => request.put(`/api/activity/${id}`, data)

// 删除活动
export const apiDeleteActivity = id => request.delete(`/api/activity/${id}`)

// 获取待处理活动
export const apiGetPendingActivities = data => request.post('/api/activities/pending', data)

// 活动报名/参与
export const apiJoinActivity = data => request.post('/api/activity/join', data)

// 活动录入
export const apiAddActivity = data => request.post('/api/user.Event/add', data)

// 获取活动记录
export const apiGetActivityRecords = data => request.post('/api/user.Event/active', data)

// 获取历史记录
export const apiGetHistoryRecords = data => request.post('/api/user.Event/history', data)

// ========== 检查记录相关 ==========
// 获取检查记录列表
export const apiGetInspectionRecords = data => request.post('/api/inspection/records', data)

// 添加检查记录
export const apiAddInspectionRecord = data => request.post('/api/inspection/record', data)

// 获取检查记录详情
export const apiGetInspectionDetail = id => request.post(`/api/inspection/${id}`)

// 获取巡检任务列表
export const apiGetInspectionTasks = data => request.post('/api/user.Event/check', data)

// ========== 文件上传相关 ==========
// 上传图片
export const apiUploadImage = data => request.post('/api/upload/image', data)

// 上传文件
export const apiUploadFile = data => request.post('/api/upload/file', data)

// 通用文件上传接口 - /api/Ajax/upload
// 参数：filePath(文件路径), extraData(额外的FormData数据), fieldName(文件字段名，默认'file')
export const apiUpload = (filePath, extraData = {}, fieldName = 'file') => request.upload('/api/Ajax/upload', filePath, fieldName, extraData)

// FormData格式文件上传 - 支持完整的FormData格式
// formDataObj格式: { filePath, fieldName, ...otherFormData }
export const apiUploadFormData = (formDataObj) => request.uploadFormData('/api/Ajax/upload', formDataObj)

// ========== 系统配置相关 ==========
// 获取系统配置
export const apiGetSystemConfig = () => request.post('/api/system/config')

// 获取应用版本信息
export const apiGetAppVersion = () => request.post('/api/app/version', {}, false)

// ========== 统计数据相关 ==========
// 获取首页统计数据（工作台接口）
export const apiGetHomeStatistics = data => request.post('/api/user.statistics/get', data)

// 获取护理统计
export const apiGetCareStatistics = data => request.post('/api/statistics/care', data)

// 获取活动统计
export const apiGetActivityStatistics = data => request.post('/api/statistics/activity', data)
